#!/Users/timmenzies/opt/gawk/bin/gawk -f 
 
# mwuTest.awk
# Revision: 296
# Built by timmenzies on Fri Jul 29 20:43:58 PDT 2011.

#   _ _ _                                               ((
#  |=|=|=|.----------------------------------------.    _))_
#  |-|-|-|| AWK code of a tiny book on data mining | ___\__/)_
#  |_|_|_|'----------------------------------------| |_|_~~_|_|

# This file is part of TINY.
#
# TINY is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# TINY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
#  along with TINY.  If not, see <http://www.gnu.org/licenses/>.

 @include "mwu.awk"
 function Mwu() {
       print "1,  1 " Mwu1(1,1)
       print "0.5,1 " Mwu1(0.5,1)
       print "2,  1 " Mwu1(2,1)
       print "1,  0 " Mwu1(1,0)
       print "0.5,0 " Mwu1(0.5,0)
       print "2,  0 " Mwu1(2,0)
 }
 function Mwu1(mult,up,   pop1,pop2,out,i) {
       mult = mult ? mult : 1
       s2a("1 4.6 2 4.7 3 4.9 "	\
	   "4 5.1 5 5.2 6 5.5 "	 \
	   "7 5.8 8 6.1 9 6.5 "	  \
	   "10 6.5 11 7.2",pop1," ")
       s2a("1 5.2 2 5.3 3 5.4 "	 \
	   "4 5.6 5 6.2 6 6.3 "	  \
	   "7 6.8 8 7.7 9 8.0 "	   \
	   "10 8.1", pop2," ")
       for(i in pop1) pop1[i] *= mult
       out = mwu(pop1,pop2,up,criticalValue(95))
       if (out == 0)
	   return "tie"
       else if (out > 0)
	   return "win for a"
       else if (out < 0)
	   return "loss for a"
 }

